home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Magazin/MacEasy 11
/
Mac Magazin and MacEasy Magazine CD - Issue 11.iso
/
Sharewarebibliothek
/
Newton
/
dontask folder
/
dontask.nwt
next >
Wrap
Text File
|
1995-06-07
|
10KB
|
237 lines
Notes
{labels: 'NIL, viewFont: 10241} // nil=Unfiled, or specify a folder, e.g., 'Business. remove viewFont for current Styles default
//ERASE! remove initial // to erase existing entries in this folder first
dontask.nwt -- Slurpee format
6/7/95
Copyright 1995 S. Weyer. All Rights Reserved Worldwide.
Keywords: keyboard, prompt, source, Newt
Don't Ask (Don't Tell) is a simple, tiny app (autopart) that adds a button (at
lower left) in the standard keyboard so that you can turn off/on the "Do you
want to add..." prompt, which you may find annoying or sometimes desirable...
When dot is hollow (default), words pass through to the dictionary prompt.
When dot is solid, the dictionary prompt does not appear (it's blocked/overridden).
This Newt source file (dontask.nwt) and the associated Newt-generated
package (DontAsk.pkg) are shareware ($5) and may be distributed freely as
long as both files are included and unmodified. You are free to make
modifications for your own use.
For your convenience, I have attached a package generated by the Newt
Development Environment* so that you don't have to compile & save this
yourself -- just install using NCK, Package Installer or a shareware
downloader. If you would like to build or modify the Don't Ask application,
you can use Newt (3.0 or greater) (see directions at end); you can avoid
re-entering the source by transferring dontask.nwt with a utility such as
Slurpee (1.5).
*Newt is an environment for developing applications using NewtonScript and
saving as packages directly on your Newton (you can also use a PC or Mac for
source editing and application debugging). Newt is shareware -- registered
users receive files containing current releases, additional packages, 165+
source examples, and a 80+ pp. (paper or Acrobat) manual describing Newt
features and NewtonScript syntax and functions. For more information,
browse http://www.netaxs.com/~weyer, or consult the Newt FAQ on AOL,
eWorld, AppleLink, Compuserve, newton.uiowa.edu or ftp.amug.org
(or send me email: weyer@netaxs.com).
Disclaimers: Don't Ask relies on undocumented behavior of the built-in
keyboard so it is not guaranteed to work on future Newtons or software
configurations. It appears not to interfere with the Graffiti kbd patch --
either in setup behavior or location (Graffiti button appears on right,
DontAsk on left). If you're aware of keyboard related conflicts, let me know
and I will contact other developers to see if we can coordinate our patches.
DontAsk generally installs & removes itself properly. However, if it is
installed on a card and you remove the card while the keyboard is open, you
will get a "Newton Still Needs the Card" message (just close the kbd first;
or install DontAsk in internal; or we could modify the button to consume more
heap).
Implementation notes: this could be even simpler -- don't add a button, just
always turn off the prompt -- but it seemed to me that there might be
occasions where you might want to turn prompting back on. It could be more
complex -- behavior controlled via a Preference panel, but that would
require many taps to switch back and forth.
You can send questions, feature requests, and registrations for DontAsk ($5)
or Newt ($45) [please include your email address, if any] to:
Steve Weyer
17 Timber Knoll Drive
Washington Crossing, PA 18977-1052
Internet: weyer@netaxs.com
http://www.netaxs.com/~weyer
America Online/eWorld/NewtonMail: SteveWeyer
Compuserve: 74603,2051
Since DontAsk is such a simple app, I don't have any major enhancments planned.
If you do register, you'll encourage me to write, release (and inform you
about) other utilities and source examples.
----------
init
//:init()
begin
:DefConst('kSize,5); // dot size
end
----------
DontAsk
//:doObj('build,'DontAsk)
//:saveApp(DontAsk)
{// a simple "button".
// a checkbox might be nicer but there's no really no room in kbd
// and adding a Preference panel seems very inconvenient to user
// note: constants can be defined symbolically with optional viewcnst.pkg plug-in
viewclass: clView, // just a vanilla view
viewFlags: 513, // vClickable + vVisible
viewBounds: RelBounds(22,-7,kSize,kSize), // left,top,width,height. left&top relative to left&bottom, between Dict icon & Option
viewJustify: 128, // vjParentBottomV (left, bottom aligned)
viewDrawScript: func()
:DrawShape(MakeOval(0,0,kSize,kSize), // left,top,right,bottom
{transferMode: 0, // modeCopy
fillPattern: if askWords
then 0 // vfFillWhite
else 5, // vfFillBlack
}),
viewClickScript: func(unit)
begin
askWords := not askWords; // toggle in parent (alphakeyboard)
:dirty(); // redraw. returns TRUE
end,
_package: {
version: 10,
copyright: "\u00A9\u 1995, S. Weyer",
devSignature: "TKnollSys", // appSymbol => DontAsk:TKnollSys
//installScript -- add these separately for editing convenience
//removeScript
//partData -- this is an autopart
},
}
----------
DontAsk._package.installScript
//:installApp(DontAsk,true)
func(partFrame,removeFrame)
begin
local slot,val, kbd := GetRoot().alphaKeyboard;
// we could check visibility & redo children. simpler just to close it...
kbd:close();
// copy some values into built-in keyboard VIEW
// and stash slots in removeFrame for later cleanup
foreach slot,val in partFrame.partData
do begin
slot := EnsureInternal(slot);
removeFrame.(slot) := kbd.(slot) := val;
end;
// button appears next time kbd opened
end
----------
DontAsk._package.removeScript
//:installApp(DontAsk,nil)
func(removeFrame)
begin
local slot, val, kbd := GetRoot().alphaKeyboard;
// we could check visibility & redo children. simpler just to close it...
kbd:close(); // if kbd still open & card is removed, then "Newton Still Needs the Card" !
// remove slots we added in installScript
foreach slot,val in removeFrame
do RemoveSlot(kbd,slot);
end
----------
DontAsk._package.partData
{// slots to add to the keyboard view
// this is set each system reset/card insertion; could store in a system preference?
askWords: true, // prompt as usual (default). modified in DontAsk.viewClickScript. used in kbd.keywordScript & DontAsk.viewDrawScript
dontAskTemplate: DontAsk._proto, // the "button" template, to be added as a child in kbd.viewSetupChildrenScript
keywordScript: func(x)
if askWords
then inherited:keywordScript(x) // default (prompt) behavior
else NIL, // don't prompt
viewSetupChildrenScript: func()
if shrunken // only do this if prompt isn't being displayed
then begin
// I think Graffiti patch adds a viewSetupFormScript method
// and sets stepChildren there, so this seems to peacefully coexist...
if not stepChildren
then stepChildren := [];
AddArraySlot(stepChildren,dontAskTemplate);
end,
}
----------
I will provide a few suggestions here on how to modify, build & test this
application. Of course, I would recommend registering for Newt to obtain more
documentation and examples...
- transfer source to the Notepad (use Slurpee, NCK or ...)
- install Newt 3.0 & NewtPack. note: if you have an Original MessagePad with
pre-1.3 ROMs, you won't be able to save this app as a package with Newt 3.0;
saving packages on OMP works in 3.1 (but this may not be publicly available yet)
- if you installed the DontAsk:TKnollSys package, remove it via Card:Remove Software;
or, use Remove Package command (under action button) once you are in Newt --
otherwise, you won't be able to install&test during development (though you could
just build & save(replace)).
- start Newt. select folder with source (default is Unfiled)
- make any edits, for example:
change location of button, RelBounds(21,-8,kSize,kSize) in DontAsk's viewBounds slot // move left & up 1
change shape of button, MakeRect instead of MakeOval in DontAsk's viewDrawScript method
change size of button, :DefConst('kSize,7) in init method
to redefine constant. tap Expr. select :init(). tap Eval
change fill of button, 4 (for vfFillDkGray) instead of 5 (for vfFillBlack)
in DontAsk's viewDrawScript method
so, now button would be a 7x7 square instead of 5x5 circle
- build application: tap Expr. select :doObj('build,'DontAsk). Eval
- install application temporarily (run its installScript, etc.)
tap Expr. select :installApp(DontAsk,true). Eval
- double-tap in text area to get standard keyboard.
(note: Newt's keyboard (via icon) is a different keyboard object, so does
not have this button currently).
- optional. tap Expr. select :installApp(DontAsk,nil). Eval
to un-install app. (this isn't strictly necessary since build or save
ensure it is un-installed).
- possibly iterate through additional edit/build/install cycles.
- to save package, tap Expr. select :saveApp(DontAsk). Eval
- exit Newt. double-tap to see keyboard.
- to confirm installScript/removeScript behavior
close keyboard
unlock or remove card
double-tap to get keyboard (no button should be present)
lock or insert card
keyboard closes (if open)
double-tap for keyboard (button should be present)
- congratulations! you have just created, tested and installed a custom autopart
- to give the new package to your friends:
backup Newton using NCK.
use Extract Package application (see www.netaxs.com/~weyer for URLs for Mac
and Windows versions) to extract package from NCK bacup file. (Windows version
may display package name generically as "package0xxxx" -- you can compare size
of file with package in Newton's Remove Software/Package menu)
---------
BYE!